package com.czk.practice.server.handler;

import com.czk.practice.domain.Message1;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/8/19 15:17
 */
public class MsgHandler1 extends SimpleChannelInboundHandler<Message1> {
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Message1 message1) throws Exception {
        //
        System.out.println("服务器收到，其字节码是"+message1.getClass().getName());
        // 内容是
        System.out.println("msg1="+new String(message1.getContent()));
        Message1 msg1=new Message1();
        msg1.setContent("czk".getBytes());
        msg1.setLen(message1.getContent().length);
        channelHandlerContext.writeAndFlush(msg1);
    }
}
